package distributedbank.requests;
import java.io.Serializable;
import java.io.IOException;

import distributedbank.server.BankBranch;
import distributedbank.Wrapper;

/**
 * A request is intended for transmission over the network to
 * a bank branch. A request is able to serialize/de-serialize itself after
 * being read from the network. It is also able to execute itself on
 * a BankBranch using the runRequest method.
 *
 * There are multiple types of Requests; each different type is represented by
 * a class that extends the Request class.
 */
public abstract class Request implements Serializable {
    protected int transactionId;
    protected int accountId; // account ID not including digits for branch id
    protected int branchId;

    public Request(int branchId, int accountId, int transactionId) {
        this.accountId = accountId;
        this.branchId = branchId;
        this.transactionId = transactionId;
    }
    public abstract void runRequest(BankBranch bankBranch, Wrapper wrapper)
                         throws IOException;
}